package shared

import (
	"github.com/facebook/ent"
	"github.com/facebook/ent/schema/field"
	"github.com/facebook/ent/schema/mixin"
	"time"
)

type TimeMixin struct {
	mixin.Schema
}

func (TimeMixin) Fields() []ent.Field {
	return []ent.Field{
		field.Time("dateCreated").
			Default(time.Now).
			// Immutable fields are fields that can be set only in the creation of the entity. i.e., no setters will be generated for the entity updater.
			Immutable(),
		field.Time("lastUpdated").
			Default(time.Now).
			UpdateDefault(time.Now),
	}
}
